#!/bin/sh
#
# ocos command
# g_CAPD_SRDC_OS@tencent.com
#
. /usr/lib/opencloudos-tools/sys-manage/ocos-lib.sh
scriptversion=4.1;
scriptdate=2022-06-02;

usage="\
ocos version $scriptversion
Usage:
    ocos OpenCloudOS Server System Management Toolset

    ocos -a | -A | analyze                      Analyze the system performance 
    ocos -b | -B | backup  [ reboot ]           Backup the system online, or reboot to backup 
    ocos -c | -C | check   [ rpm_name ]         Check the modified rpms
    ocos -r | -R | recover | reinstall          Recover or Reinstall the system
    ocos -u | -U | update  [ rpm_name ]         Update the system 
    ocos -i | -I | install [ rpm_name ]         install rpms
    ocos -s | -S | show                         Show the system version
    ocos -ch| check-health [ -o OUTPUT_PATH ]   Check system health status
    ocos -cu| check-update                      Check available package updates
    ocos ops ...                                Operation tools
    ocos -h | -H | help                         Show this usage
    ocos -v | -V | version                      Show the script version

"

if [[ "$0" =~ (^|/)oc-ops$ ]]; then
    ops $@
fi

if [ $# -eq 0 ]; then
    echo "$usage"
    ocos_show;
fi

while test $# -ne 0; do
    case $1 in
        -u | update) shift
            ocos_update $@
            break;;
        -i | -I | install) shift
            ocos_install $@
            break;;
        -s | -S | show)
            ocos_show;;
        -a | -A | analyze)
            ocos_analyze $2
		    break;;
        -b | -B | backup)
            ocos_backup $2
            break;;
        -r | -R | recover | reinstall) shift
            ocos_recover $@
            break;;
        -c | -C | check) ocos_check $2
            shift;;
        -cu | check-update) ocos_check_update;;
        -ch | check-health) shift
            ocos_check_health $@
            break;;
        ops) shift; ops "$@"
            break;;
        -h | -H | help) echo "$usage"; exit $?;;
        -v | -V | version) echo "$scriptversion";;
        --) shift
            break;;
        *) echo "$0: invalid option: $1" >&2
            echo "$usage"
            exit 1;;
     esac
     shift
done


